Socket
Socket
Sign inDemoInstall

jss

Package Overview
Dependencies
Maintainers
1
Versions
186
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss

A lib for generating Style Sheets with JavaScript.


Version published
Weekly downloads
2.3M
increased by7.8%
Maintainers
1
Weekly downloads
 
Created

What is jss?

JSS (JavaScript Style Sheets) is a library for generating CSS styles with JavaScript. It allows you to define styles in a JavaScript object and apply them to your components, making it easier to manage and maintain styles in a JavaScript-centric development environment.

What are jss's main functionalities?

Creating Styles

This feature allows you to create styles using JavaScript objects. The `createStyleSheet` method generates a stylesheet from the provided styles and attaches it to the document.

const styles = {
  button: {
    color: 'blue',
    background: 'white',
    border: '1px solid blue'
  }
};

const { classes } = jss.createStyleSheet(styles).attach();

// Usage in a component
const button = document.createElement('button');
button.className = classes.button;
button.textContent = 'Click me';
document.body.appendChild(button);

Dynamic Styles

This feature allows you to create dynamic styles that can change based on props or state. The `update` method is used to update the styles with new values.

const styles = {
  button: {
    color: props => props.color,
    background: 'white',
    border: '1px solid blue'
  }
};

const sheet = jss.createStyleSheet(styles);
const { classes } = sheet.update({ color: 'red' }).attach();

// Usage in a component
const button = document.createElement('button');
button.className = classes.button;
button.textContent = 'Click me';
document.body.appendChild(button);

Theming

This feature allows you to create themes that can be applied to your styles. The styles can reference theme variables, making it easy to switch themes or update theme values.

const theme = {
  primaryColor: 'blue',
  secondaryColor: 'green'
};

const styles = theme => ({
  button: {
    color: theme.primaryColor,
    background: 'white',
    border: `1px solid ${theme.primaryColor}`
  }
});

const sheet = jss.createStyleSheet(styles(theme)).attach();
const { classes } = sheet;

// Usage in a component
const button = document.createElement('button');
button.className = classes.button;
button.textContent = 'Click me';
document.body.appendChild(button);

Other packages similar to jss

Keywords

FAQs

Package last updated on 09 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc